package com.cskaoyan.controller.wxgoods;

import com.cskaoyan.bean.bo.WxGoodsListBO;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.vo.WXGoodsCategoryVo;
import com.cskaoyan.bean.vo.WXGoodsDetailVo;
import com.cskaoyan.bean.vo.WXGoodsListVo;
import com.cskaoyan.bean.vo.WXGoodsRelatedVo;
import com.cskaoyan.service.AdminGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("wx/goods")
public class WXGoodsController {
    @Autowired
    AdminGoodsService adminGoodsService;

    @GetMapping("count")
    public BaseRespVo getGoodsCount(){
        Integer count = adminGoodsService.getWXGoodsCount();
        return BaseRespVo.ok(count);
    }

    @GetMapping("category")
    public BaseRespVo getGoodsCategory(Integer id){
        WXGoodsCategoryVo categoryVo = adminGoodsService.getWXGoodsCategory(id);
        return BaseRespVo.ok(categoryVo);
    }

    @GetMapping("list")
    public BaseRespVo getGoodsList(@Valid WxGoodsListBO wxGoodsListBO){
        WXGoodsListVo goodsListVo = adminGoodsService.getWXGoodsList(wxGoodsListBO);
        return BaseRespVo.ok(goodsListVo);
    }

    @GetMapping("detail")
    public BaseRespVo getGoodsDetail(Integer id){
        WXGoodsDetailVo detailVo = adminGoodsService.getWXGoodsDetail(id);
        return BaseRespVo.ok(detailVo);
    }

    @GetMapping("related")
    public BaseRespVo getGoodsRelated(Integer id){
        WXGoodsRelatedVo relatedVo = adminGoodsService.getWXGoodsRelated(id);
        return BaseRespVo.ok(relatedVo);
    }
}
